package gogitstarter

import (
	"embed"

	"bitwormhole.com/djaf/go-git-starter/gen/cfgdemo"
	"bitwormhole.com/djaf/go-git-starter/gen/cfggogit"
	"bitwormhole.com/starter/cli/libcli"
	"github.com/bitwormhole/starter"
	"github.com/bitwormhole/starter/application"
	"github.com/bitwormhole/starter/collection"
)

const (
	theModuleName     = "bitwormhole.com/djaf/go-git-starter"
	theModuleVersion  = "v0.0.1"
	theModuleRevision = 1
	theModuleResPath  = "src/main/resources"
)

//go:embed "src/main/resources"
var theModuleResFS embed.FS

// Module ... export module "go-git-starter"
func Module() application.Module {
	mb := application.ModuleBuilder{}

	mb.Name(theModuleName)
	mb.Version(theModuleVersion)
	mb.Revision(theModuleRevision)

	mb.OnMount(cfggogit.ExportConfig)
	mb.Resources(collection.LoadEmbedResources(&theModuleResFS, theModuleResPath))

	mb.Dependency(starter.Module())

	return mb.Create()
}

////////////////////////////////////////////////////////////////////////////////

//go:embed "src/test/resources"
var theModuleTestResFS embed.FS

// ModuleForDemo ...
func ModuleForDemo() application.Module {

	const resPath = "src/test/resources"
	parent := Module()
	mb := application.ModuleBuilder{}

	mb.Name(parent.GetName() + "#demo")
	mb.Version(parent.GetVersion())
	mb.Revision(parent.GetRevision())

	mb.OnMount(cfgdemo.ExportConfig)
	mb.Resources(collection.LoadEmbedResources(&theModuleTestResFS, resPath))

	mb.Dependency(parent)
	mb.Dependency(libcli.Module())

	return mb.Create()
}
